<html>
  <head>
    <script src="lib/jquery.js"></script>
    <script src="lib/json2.js"></script>
    <script src="lib/google-jstemplate/util.js"></script>
    <script src="lib/google-jstemplate/jsevalcontext.js"></script>
    <script src="lib/google-jstemplate/jstemplate.js"></script>
    <script src="lib/parse-js.js"></script>
    <script src="expressions.js"></script>
    <script src="querycollector.js"></script>
    <script src="mqlconnection.js"></script>
    <script src="templateprocessor.js"></script>
    <script src="update.js"></script>
  </head>
  <body>
    <div id="content"></div>
    <div id="templates" style="display:none"></div>
  </body>

<script>


var path = [];
parsePath("foo.bar['baz']", path);
console.log(path);

// Template loader
window.onhashchange = function(event) {
   console.log(event);
   console.log(window.location.hash);
   var hash = window.location.hash;
   if (hash.length < 2) {
     hash = "people";
   } else {
     hash = hash.substring(1);
   }
   var cut = hash.indexOf('?');
   var templateName;
   var context = new JsEvalContext({});
   if (cut == -1) {
     templateName = hash;
   } else {
     templateName = hash.substring(0, cut);
     var query = hash.substring(cut + 1);
     var parts = query.split('&');
     for (var i = 0; i < parts.length; i++) {
       var part = parts[i];
       var cut2 = part.indexOf('=');
       if (cut2 != -1) {
         var varName = part.substring(0, cut2);
         var value = part.substring(cut2 + 1)
         context.setVariable(varName, value);
       }
     }
   }
   
   console.log("Context: " + context);
   
   renderTemplate(templateName, context);
}

window.onhashchange(null);


</script>
</body>
